<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * 接口测试
 * @author www.dingwei.cn
 */
class Test extends CI_Controller {
    
    public $baseUrl = 'http://139.199.211.51/gebi/';
	
	public function index(){

	}
	
	/**
	 * 注册验证吗
	 */
	public function getVerifyCode(){
	    $url = $this->baseUrl.'deliveryman/app/user/getVerifyCode';
        $param = array(
            'mobile' => '15086856521',
            'key' => '5a601759a24019333332',
            'code' => 351100,
            'type' => 5,
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 注册验证吗
	 */
	public function verifyMobileCode(){
	    $url = $this->baseUrl.'deliveryman/app/user/verifyMobileCode';
        $param = array(
            'mobile' => '15086856521',
            'code' => 99003,
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 注册
	 */
	public function register(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/user/register';
        $param = array(
            'mobile' => '15086856521',
            'code' => 99003,
        	'password' => '123456',
        	're_password' => '123456',
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 登录
	 */
	public function login(){
        $url = 'http://139.199.211.51/gebi/deliveryman/app/user/login';
        $param = array(
            'mobile' => '15086856521',
        	'password' => 'ft0172',
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 忘记密码
	 */
	public function forgetPassword(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/user/forgetPassword';
        $param = array(
            'mobile' => '15086856521',
        	'old_password' => '22595',	
        	'password' => 'ft0172',
        	're_password' => 'ft0172',
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 修改密码
	 */
	public function password(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/user/password';
        $param = array(
        	'sessionid' => encode('3075fe839d0b9a6e62f79d7dd1c29241e72d6d67'),
        	'old_password' => 'ft0172',	
        	'password' => 'ft0172',
        	're_password' => 'ft0172',
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 更换手机号码
	 */
	public function changeMobile(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/user/changeMobile';
        $param = array(
        	'sessionid' => encode('23fb1b7c133518f9baeae75bf4137ef746557d76'),
        	'mobile' => '15086856522',	
        	'code' => '16231',
        	'old_code' => '58672',
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 设置支付密码
	 */
	public function setPayPasswd(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/user/setPayPasswd';
        $param = array(
        	'sessionid' => encode('61b3b1cde3695cfc7e9e56b9171cd2d93a790793'),
        	'code' => '41890',
        	'password' => '123456',
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 认证
	 */
	public function auth(){
        $url = 'http://139.199.211.51/gebi/deliveryman/app/user/auth';
        $param = array(
        	'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
        	'name' => '李海平',
            'province_id' => 1,
            'city_id' => 35,
            'county_id' => 408,
        	'identity_card' => '500236199009102879',
        	'portrait' => new CURLFile('D:\IMG_20170329_171111.jpg'),
        	'identity_card_img' => new CURLFile('D:\IMG_20170329_171111.jpg'),
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 设置接受订单类型
	 */
	public function orderType(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/user/orderType';
        $param = array(
        	'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
        	'type' => '1,2,3',
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 获取订单类型
	 */
	public function getorderType(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/order/type';
        $param = array(
        	'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 设置工作状态
	 */
    public function workStatus(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/user/workStatus';
        $param = array(
        	'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
        	'status' => 1,
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 获取用户详细信息
	 */
	public function getInfo(){
        $url = 'http://139.199.211.51/gebi/deliveryman/app/user/getInfo';
        $param = array(
        	'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 获取银行列表
	 */
	public function getBanks(){
        $url = 'http://139.199.211.51/gebi/deliveryman/app/common/getBanks';
        $param = array(
        	'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 添加银行
	 */
	public function saveBankCard(){
        $url = 'http://139.199.211.51/gebi/deliveryman/app/user/saveBankCard';
        $param = array(
        	'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
        	'bank_id' => 4,
        	'code' => '6222033100003092965',
        );
        $this->_request($url, $param);
    }
    
    /**
     * 获取银行卡列表
     */
    public function getBankCardList(){
    	
    	$url = 'http://139.199.211.51/gebi/deliveryman/app/user/getBankCardList';
    	$param = array(
    			'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
    	);
    	$this->_request($url, $param);
    }
    
    /**
     * 获取银行卡列表
     */
    public function verifyPayPassword(){
    	
    	$url = 'http://139.199.211.51/deliveryman/deliveryman/app/user/verifyPayPassword';
    	$param = array(
    			'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
    	        'password' => 123456
    	);
    	$this->_request($url, $param);
    }
    
	/**
	 * 删除银行银行
	 */
	public function deleteBankCard(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/user/deleteBankCard';
        $param = array(
        	'sessionid' => encode('6bf3c78f2da5ef28e0113a3c1c8b9d10cf7d0356'),
        	'id' => 1
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 提现申请
	 */
	public function withdrawCash(){
        $url = 'http://139.199.211.51/gebi/deliveryman/app/user/withdrawCash';
        $param = array(
        	'sessionid' => encode('66ec501e0014cd28cf1cc5593a0b9dde4366c8f6'),
            'card_id' => 11,
            'password' => 123456,
        	'amount' => 2
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 获取余额详情
	 */
	public function getAmountDetails(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/user/getAmountDetails';
        $param = array(
        	'sessionid' => encode('6bf3c78f2da5ef28e0113a3c1c8b9d10cf7d0356'),
        	'page' => 1,
        	'date' => date('2017-08-06')
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 获取余额详情
	 */
	public function getMessageList(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/user/getMessageList';
        $param = array(
        	'sessionid' => encode('6bf3c78f2da5ef28e0113a3c1c8b9d10cf7d0356'),
        	'page' => 1
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 删除消息
	 */
	public function deleteMessage(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/user/deleteMessage';
        $param = array(
        	'sessionid' => encode('6bf3c78f2da5ef28e0113a3c1c8b9d10cf7d0356'),
        	'id' => 2
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 添加反馈
	 */
	public function addFeedback(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/user/addFeedback';
        $param = array(
        	'sessionid' => encode('6bf3c78f2da5ef28e0113a3c1c8b9d10cf7d0356'),
        	'content' => '需要改进，需要改进，'
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 反馈列表
	 */
	public function getFeedbackList(){
        $url = 'http://139.199.211.51/gebi/deliveryman/app/user/getFeedbackList';
        $param = array(
        	'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
        	'page' => 1
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 获取订单列表
	 */
	public function getOrderList(){
        $url = 'http://139.199.211.51/gebi/deliveryman/app/order/getList';
        $param = array(
        	'sessionid' => encode('b8798f632a3d10ee979d5c7576bc7ce0ec797387'),
        	'latitude' => 29.6,
        	'longitude' => 106.604, 
        	'status' => 1,
        	'page' => 1,
        	'order' => 0
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 抢单
	 */
	public function addOrder(){
        $url = 'http://localhost/gebinew/gebi/deliveryman/app/order/add';
        $param = array(
        	'sessionid' => encode('897a8150d9f8d1cb855922566b0ea3f53662a856'),
        	'id' => 48
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 取货
	 */
	public function pickupOrder(){
        $url = 'http://localhost/gebinew/gebi/deliveryman/app/order/pickup';
        $param = array(
        	'sessionid' => encode('1f1c8aa595bcd435e39fc5034404285b5f13a18c'),
        	'id' => 48
        );
        $this->_request($url, $param);
    }
    /**
     * 取货
     */
    public function getMessageCount(){
        $url = 'http://localhost/gebinew/gebi/deliveryman/app/user/getMessageCount';
        $param = array(
            'sessionid' => encode('9c81049b198e963ac5e4ffb16a4869e73520702e'),
            'id' => 48
        );
        $this->_request($url, $param);
    }
	/**
	 * 已完成
	 */
	public function completeOrder(){
        $url = 'http://139.199.211.51/gebi/deliveryman/app/order/complete';
        $param = array(
        	'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
        	'id' => 1
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 获取完成统计
	 */
	public function getTodayData(){
        $url = 'http://192.168.1.31/gebinew/gebi/deliveryman/app/order/getTodayData';
        $param = array(
        	'sessionid' => encode('897a8150d9f8d1cb855922566b0ea3f53662a856'),
        );
        $this->_request($url, $param);
    }
    
	/**
	 * 异常报备
	 */
	public function abnormalOrder(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/order/abnormal';
        $param = array(
        	'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
        	'id' => 1,
        	'type' => 1,
        	'content' => '内容'
        );
        
        $this->_request($url, $param);
    }
    
	/**
	 * 完成订单列表
	 */
	public function orderCompleteList(){
        $url = 'http://192.168.1.31/gebinew/gebi/deliveryman/app/order/completeList';
        $param = array(
        	'sessionid' => encode('897a8150d9f8d1cb855922566b0ea3f53662a856'),
        	'page' => 1,
        	'date' => '2018-02-24'
        );
        p($param);
        $this->_request($url, $param);
    }
    
	/**
	 * 获取报备列表
	 */
	public function apList(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/order/apList';
        $param = array(
        	'sessionid' => encode('8ecf1b3c5eb6137f3b60c986fa5ef319bb07baca'),
        	'page' => 1,
        	'date' => '2017-12-11'
        );
        
        $this->_request($url, $param);
    }
    
    /**
     * 获取异常报备配置
     */
    public function apConfig(){
        $url = 'http://139.199.211.51/gebi/deliveryman/app/order/apConfig';
        $param = array(
            'sessionid' => encode('1db868cfd9c48df51bf90634460d276cbfbbe9dc'),
            'page' => 1,
        );
        
        $this->_request($url, $param);
    }
    
	/**
	 * 获取运单详情
	 */
	public function getOrderInfo(){
        $url = 'http://139.199.211.51/gebi/deliveryman/app/order/getInfo';
        $param = array(
        	'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
        	'id' => 1,
        );
        
        $this->_request($url, $param);
    }
    
	/**
	 * 实时定位
	 */
	public function postion(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/user/postion';
        $param = array(
        	'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
        	'longitude' => 1,
        	'latitude' => 1,
        );
        
        $this->_request($url, $param);
    }
    
	/**
	 * 获取客户电话
	 */
	public function getCustomerTel(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/common/getCustomerTel';
        $param = array(
        	'sessionid' => encode('8ecf1b3c5eb6137f3b60c986fa5ef319bb07baca'),
        );
        
        $this->_request($url, $param);
    }
    
	/**
	 * 关于我们接口
	 */
	public function aboutBs(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/common/aboutBs';
        $param = array(
        	'sessionid' => encode('8ecf1b3c5eb6137f3b60c986fa5ef319bb07baca'),
        );
        
        $this->_request($url, $param);
    }
    
	/**
	 * 提现说明
	 */
    public function withdraw(){
        $url = 'http://139.199.211.51/deliveryman/deliveryman/app/common/withdraw';
        $param = array(
        	'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
        );
        
        $this->_request($url, $param);
    }
    
	/**
	 * 关于我们接口
	 */
    public function getArea(){
        $url = 'http://139.199.211.51/gebi/deliveryman/app/common/getArea';
        $param = array(
        	'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
            'pid' => 0
        );
        
        $this->_request($url, $param);
    }
    
    /**
     * 预计收益说明
     */
    public function income(){
        $url = 'http://139.199.211.51/gebi/deliveryman/app/common/income';
        $param = array(
            'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
        );
        
        $this->_request($url, $param);
    }
    
    /**
     * 预计收益说明
     */
    public function update(){
        $url = 'http://139.199.211.51/gebi/deliveryman/app/common/update';
        $param = array(
        );
        
        $this->_request($url, $param);
    }
    
    /**
     * 预计收益说明
     */
    public function captcha(){
        $url = 'http://139.199.211.51/gebi/deliveryman/app/common/captcha';
        $param = array(
        );
        
        $this->_request($url, $param);
    }
    
    /**
     * 注册协议
     */
    public function agreement(){
        $url = 'http://139.199.211.51/gebi/deliveryman/app/common/agreement';
        $param = array(
        );
        
        $this->_request($url, $param);
    }

    /**
     * 获取分享信息
     */
    public function getSharp(){
        $url = 'http://192.168.1.35/gebi/deliveryman/app/common/getSharp';
        $param = array(
            'sessionid' => encode('5503b5c4e2950e113ba9f3981d2a3453613e55eb'),
        );

        $this->_request($url, $param);
    }
	
	/**
	 * 请求接口
	 * 
	 * @param	string	$url	请求路径
	 * @param 	array 	$param	请求参数
	 */
	private function _request($url, $param){
		
		$curl = curl_init();
	    curl_setopt($curl, CURLOPT_URL, $url);
	    curl_setopt($curl, CURLOPT_HEADER, 0);
	    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
	    curl_setopt($curl, CURLOPT_POST, true);
	    curl_setopt($curl, CURLOPT_POSTFIELDS, $param);
	    curl_setopt($curl, CURLOPT_TIMEOUT, 30);
	    $data = curl_exec($curl);
	    if(curl_errno($curl)){
	    	p(curl_error($curl));
	    	exit(array('status' => 0, 'data' => NULL, 'message' => curl_error($curl)));
		}
	    curl_close($curl);
	    echo $data;
	}
}
